package com.yl.auth.controller;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yl.auth.model.entity.XingZhengChaFangXiangQing;
import com.yl.auth.service.XingZhengChaFangXiangQingService;
import com.yl.common.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author L
 * @since 2023-06-27
 */
@Api(tags = "行政查房详情")
@RestController
@RequestMapping("/admin/yanglao/xingzhengchafangxiangqing")
public class XingZhengChaFangXiangQingController {
    @Resource
    private XingZhengChaFangXiangQingService xingZhengChaFangXiangQingService;

    @ApiOperation("根据查房人Id查看查房详情")
    @GetMapping("/getById/{id}")
    public Result getById(@PathVariable Integer id){
        LambdaQueryWrapper<XingZhengChaFangXiangQing> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(XingZhengChaFangXiangQing::getXid,id);
        XingZhengChaFangXiangQing xingZhengChaFangXiangQing = xingZhengChaFangXiangQingService.getOne(lambdaQueryWrapper);
        return Result.ok(xingZhengChaFangXiangQing);
    }

    @ApiOperation("新增行政查房")
    @PostMapping("/save")
    public Result save(@RequestBody XingZhengChaFangXiangQing xingZhengChaFangXiangQing){
        xingZhengChaFangXiangQingService.save(xingZhengChaFangXiangQing);
        return Result.ok();
    }
    @ApiOperation("修改行政查房信息")
    @PostMapping("/update")
    public Result update(@RequestBody XingZhengChaFangXiangQing xingZhengChaFangXiangQing){
        xingZhengChaFangXiangQingService.updateById(xingZhengChaFangXiangQing);
        return Result.ok();
    }

    @ApiOperation("删除行政查房信息")
    @DeleteMapping("/deleteById/{id}")
    public Result deleteById(@PathVariable Integer id){
        xingZhengChaFangXiangQingService.removeById(id);
        return Result.ok();
    }
}